using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;

namespace LocalizationTest
{
  public class DistanceMeasurement : Measurement
  {
    private double distance;

    public DistanceMeasurement()
    {
      this.distance = 0;
      this.sensor = null;
    }

    public DistanceMeasurement(double distance, Sensor sensor)
    {
      this.distance = distance;
      this.sensor = sensor;
    }

    public override double GetValueAsDouble()
    {
      return this.distance;
    }
    public override double  GetDifference(Measurement other)
    {
      return (this.distance - ((DistanceMeasurement)other).distance);
    }

    public double Distance
    {
      get { return distance; }
    }
    public override Measurement Parse(string str, Experiment experiment)
    {
      string[] parts = str.Split('/');
      Sensor sensor = experiment.GetSensorByString(parts[0]);
      double distance = double.Parse(parts[1]);
      return new DistanceMeasurement(distance, sensor);
    }

    public override string ToString()
    {
      return (
        this.GetType().Name + "|" +
        this.sensor.ToString() + "/" +
        distance.ToString());
    }
  }
}
